import httpRequest from '@/utils/httpRequest'

export function getScheduleList (data) {
  return httpRequest({
    url: httpRequest.adornUrl('/sys/schedule/list'),
    method: 'get',
    params: httpRequest.adornParams(data)
  })
}

export function deleteSchedule (ids, openDefultdata = true) {
  return httpRequest({
    url: httpRequest.adornUrl('/sys/schedule/delete'),
    method: 'post',
    data: httpRequest.adornData(ids, openDefultdata)
  })
}

export function pauseSchedule (ids, openDefultdata = true) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/schedule/pause`),
    method: 'post',
    data: httpRequest.adornData(ids, openDefultdata)
  })
}

export function resumeSchedule (ids, openDefultdata = true) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/schedule/resume`),
    method: 'post',
    data: httpRequest.adornData(ids, openDefultdata)
  })
}

export function runSchedule (ids, openDefultdata = true) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/schedule/run`),
    method: 'post',
    data: httpRequest.adornData(ids, openDefultdata)
  })
}

export function scheduleInfoById (id) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/schedule/info/${id}`),
    method: 'get',
    params: httpRequest.adornParams()
  })
}

export function scheduleInfoSave (data) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/schedule/${!data.jobId ? 'save' : 'update'}`),
    method: 'post',
    data: httpRequest.adornData(data)
  })
}

export function getScheduleLogList (data) {
  return httpRequest({
    url: httpRequest.adornUrl('/sys/scheduleLog/list'),
    method: 'get',
    params: httpRequest.adornParams(data)
  })
}

export function scheduleLogById (id) {
  return httpRequest({
    url: httpRequest.adornUrl(`/sys/scheduleLog/info/${id}`),
    method: 'get',
    params: httpRequest.adornParams()
  })
}
